/*
 * Copyright 2009 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.splink.deepsplink.page {
	import org.splink.deepsplink.navigation.command.INavigationCommand;
	import org.splink.deepsplink.page.state.PageState;
	import org.splink.library.queue.IQable;
	import org.splink.library.tree.Tree;

	import flash.display.DisplayObjectContainer;

	/**
	 * <code>IPageSupplier</code> contains methods which are relevant
	 * for <code>IPage</code> implementations. The base class 
	 * <code>Page</code> combines the <code>IPageSupplier</code>
	 * and the <code>IPage</code> interface.
	 * 
	 * 
	 * @see org.splink.deepsplink.page.Page
	 * @see org.splink.deepsplink.page.IPageInternal
	 * @see org.splink.deepsplink.page.IPageFactoryTemplate
	 * 
	 * @author Max Kugland
	 */
	public interface IPageSupplier {

		/**
		 * Usally <code>IPage</code> implementations set a default <code>IQable</code> 
		 * strategy for showing the page. The strategy is executed after the
		 * <code>IPage</code> is initialized. Note that the strategy must be ready to
		 * get started again after it has been finalized.
		 * 
		 * @param showStrategy an <code>IQueueable</code> implementation
		 */
		function setShowStrategy(showStrategy : IQable) : IQable;

		/**
		 * Usally <code>IPage</code> implementations set a default <code>IQueueable</code> 
		 * strategy for hiding the page. The strategy is executed before the 
		 * <code>IPage</code> in finalized. Note that the strategy must be ready to
		 * get started again after it has been finalized.
		 * 
		 * @param showStrategy an <code>IQueueable</code> implementation
		 */
		function setHideStrategy(hideStrategy : IQable) : IQable;
		
		/**
		 * Propagates completion of the page initalization.
		 */
		function setInitialized() : void;

		/**
		 * Each <code>IPage</code> implementation has a unique id, which needs to be defined
		 * within the configuation xml file, or programatically withing <code>ConfigData</code>
		 * 
		 * @return the id of the page
		 */
		function get id() : String;

		/**
		 * Retrieves the title of the page
		 * 
		 * @return the title of the page
		 */
		function get title() : String;

		/**
		 * Searches the current <code>PageParameter</code> for a parameter with
		 * the given key and returns it's value
		 * 
		 * @return the value of a <code>PageParameter</code> for the given key
		 */
		function getParamValueForKey(key : String) : String;

		/**
		 * @private
		 * 
		 * A page can adopt different states, which are defines via static consts 
		 * within <code>PageStates</code>. Under special circumstances it might be
		 * useful for a page to find out what state it currently has.
		 * 
		 * @return the current state of the page.
		 * @see org.splink.deepsplink.page.state.PageStates		 * @see org.splink.deepsplink.page.state.PageState
		 */
		function get state() : PageState;

		/**
		 * A navigation command is the way of navigating a deepsplink driven application.
		 * 
		 * @return an <code>INavigationCommand</code> to provide the means to go to another page
		 */
		function get navigationCommand() : INavigationCommand;

		/**
		 * @return an array which contains <code>PageParameter</code> instances
		 */
		function get params() : Array;

		/**
		 * Returns the <code>Tree</code> instance which is a representation of the page 
		 * structure. The tree consists of <code>INode</code> instances, whose 
		 * data property holds a <code>PageData</code> instance.
		 * 
		 * Usally the <code>tree</code> is used to feed an <code>IPageNavigationModel</code> in order to
		 * build a navigation for the sub pages of the page.
		 * 
		 * @return tree the tree
		 * 
		 * @see org.splink.library.tree.INode
		 * @see org.splink.library.tree.Tree
		 * @see org.splink.deepsplink.navigation.IPageNavigationModel
		 */
		function get tree() : Tree;

		/**
		 * @return the <code>DisplayObjectContainer</code> in which the page may render.
		 */
		function get display() : DisplayObjectContainer;
	}
}
